package easy;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution_1436 {

    public String destCity(List<List<String>> paths) {
        Map<String, String> map = new HashMap<>();
        for (List<String> path : paths) {
            /*Set<String> set = map.getOrDefault(path.get(0), new HashSet<>());
            set.add(path.get(1));*/
            map.put(path.get(0), path.get(1));
        }
        String next = paths.get(0).get(1);
        while (map.containsKey(next)) {
            next = map.get(next);
        }
        return next;
    }

    public static void main(String[] args) {
        Solution_1436 model = new Solution_1436();
    }
}
